---
layout: page
home-title: Welcome to zhonger's blog!
description: Writing, writing, writing ...
permalink: /categories.html
cover: https://images.unsplash.com/photo-1465189684280-6a8fa9b19a7a?w=1600&q=900
---

{% assign category_posts_num = site.categories | size%}
{% assign uncategory_posts = site.posts | where: "categories", empty | sort: "date" | reverse %}
{% assign uncategory_posts_num = uncategory_posts | size %}

{% assign lang = page.lang | default: site.default_lang %}
{% assign locales = site.data.locales[lang] %}
{% assign categories = locales.categories%}

<h2>{{ categories.title }}</h2>

<p>
  {{ categories.total.info }} {{ site.posts | size }} {{ categories.total.unit }} 
  {% if category_posts_num > 0 %}
    {{ categories.type.info }} {{ category_posts_num }} {{ categories.type.unit }}
  {% endif %}
  {% if uncategory_posts_num > 0 %} 
    {{ categories.uncategory.info }} {{ uncategory_posts_num }} {{ categories.uncategory.unit }}
  {% endif %}
</p>

{% for category in site.categories %}
  {% assign category_name = category | first %}
  <h3 class="category">{{ category[0] }}</h3>
  <ul>
  {% for post in site.categories[category_name] %}
    <li>
      <p class="archives-title">
        <span class="archives-date">
          {% case site.formats.time %}
          {% when 0 %}
            {{ post.date | date: "%Y-%m-%d" }} 
          {% when 1 %}
            {{ post.date | date_to_string }}
          {% else %}
            {{ post.date | date: "%Y年%-m月%-d日"  }}
          {% endcase %}
        </span>
        <a href="{{ post.url | prepend: site.baseurl }}"> {{ post.title }} </a>
      </p>
    </li>
  {% endfor %}
  </ul>
{% endfor %}

{% if uncategory_posts_num > 0 %}
  <h3 class="category">{{ categories.u_title }}</h3>
  <ul>
  {% for post in uncategory_posts %}
    <li>
      <p class="archives-title">
        <span class="archives-date">
          {% case site.formats.time %}
          {% when 0 %}
            {{ post.date | date: "%Y-%m-%d" }} 
          {% when 1 %}
            {{ post.date | date_to_string }}
          {% else %}
            {{ post.date | date: "%Y年%-m月%-d日"  }}
          {% endcase %}
        </span>
        <a href="{{ post.url | prepend: site.baseurl }}"> {{ post.title }} </a>
      </p>
    </li>
  {% endfor %}
  </ul>
{% endif %}